package string.regex;

import org.junit.Test;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 字符串正则合集
 *
 * @author LoneRanger
 * @version 1.0
 */
public class StringRegexCollection {

	/**
	 * yyyy-MM-dd 字符串验证
	 */
	private static final String DATA_REGEX = "^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-" +
			"(?:0[1-9]|1[0-9]|2[0-8])|" +
			"(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}" +
			"(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$";

	@Test
	public void dateTest() {
		Pattern compile = Pattern.compile(DATA_REGEX);
		Matcher m = compile.matcher("2022-12-01");
		System.out.println(m.matches());
	}

}
